import request from '@/utils/request'

/**
 * 提交入库申请
 * @param {Array} applystockList 入库列表
 */
export function postApplyInStocks(applystockList) {
  return request({
    url: '/API/MaterialInfo/AddStockIns',
    method: 'post',
    data: { applystockList },
    successMsg: true, //请求成功通知，支持String & Boolean
    failMsg: true //请求失败通知，支持String & Boolean
  })
}

/**
 * 提交出库申请
 * @param {Array} stockoutapplylist 出库列表
 */
export function postApplyOutStocks(stockoutapplylist) {
  return request({
    url: '/API/MaterialInfo/AddStockOuts',
    method: 'post',
    data: { stockoutapplylist },
    successMsg: true, //请求成功通知，支持String & Boolean
    failMsg: true //请求失败通知，支持String & Boolean
  })
}

/**
 * 查询申请入库列表
 * @param {*} params 
 */
export function getInStocksApply(params) {
  return request({
    url: '/API/MaterialInfo/StockInApplyList',
    method: 'get',
    params,
    failMsg: true
  })
}

/**
 * 查询申请入库列表详情
 * @param {String} ApplyID 申请ID
 */
export function getApplyInItems(data) {
  return request({
    url: '/API/MaterialInfo/StockInDetailsApplyList',
    method: 'post',
    data,
    failMsg: true
  })
}

/**
 * 入库申请-审核
 * @param {String} iautoid 主键
 * @param {Number} State 状态 1=通过 2=驳回
 */
export function byStockInApply(data) {
  return request({
    url: '/API/MaterialInfo/ByStockInApply',
    method: 'post',
    data,
    successMsg: true,
    failMsg: true
  })
}

/**
 * 查询申请出库列表
 * @param {*} params 
 */
export function getOutStocksApply(params) {
  return request({
    url: '/API/MaterialInfo/StockOutApplyList',
    method: 'get',
    params,
    failMsg: true
  })
}

/**
 * 查询申请出库列表详情
 * @param {String} ApplyID 申请ID
 */
export function getApplyOutItems(data) {
  return request({
    url: '/API/MaterialInfo/StockOutDetailsApplyList',
    method: 'post',
    data,
    failMsg: true
  })
}

/**
 * 出库申请-审核
 * @param {String} iautoid 主键
 * @param {Number} State 状态 1=通过 2=驳回
 */
export function byStockOutApply(data) {
  return request({
    url: '/API/MaterialInfo/ByStockOutApply',
    method: 'post',
    data,
    successMsg: true,
    failMsg: true
  })
}

/**
 * 耗材归还
 * @param {String} inStockNo 入库编号
 * @param {Number} inCount 归还数量
 */
export function MaterialReturned(data) {
  return request({
    url: '/API/MaterialInfo/MaterialReturned',
    method: 'post',
    data,
    successMsg: true,
    failMsg: true
  })
}

/**
 * 耗材报废
 * @param {String} iautoid 入库表唯一ID
 * @param {String} description 报废描述
 */
export function MaterialsScrap(data) {
  return request({
    url: '/API/MaterialInfo/MaterialsScrap',
    method: 'post',
    data,
    successMsg: true,
    failMsg: true
  })
}